<template>
  <div>
    <el-form ref="form" :model="tableData" label-width="80px">
      <el-row>
        <el-col :span="8">
          <el-form-item label="厂牌型号">
            <el-input
              v-model="tableData.c_brand"
              placeholder="请输入厂牌型号"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="车牌号">
            <el-input
              v-model="tableData.c_plate"
              placeholder="请输入车牌号"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="所属公司">
            <el-input
              v-model="tableData.c_company"
              placeholder="请输入所属公司"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="司机姓名">
            <el-input
              v-model="tableData.c_drivername"
              placeholder="请输入司机姓名"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="车型">
            <el-input
              v-model="tableData.c_long"
              placeholder="长"
              type="Number"
            ></el-input>

            <el-input
              v-model="tableData.c_width"
              placeholder="宽"
              type="Number"
            ></el-input>

            <el-input
              v-model="tableData.c_high"
              placeholder="高"
              type="Number"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="车辆颜色">
            <el-input
              v-model="tableData.c_colour"
              placeholder="请输入车辆颜色"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="购置日期">
            <el-form-item prop="date1">
              <el-date-picker
                type="date"
                placeholder="选择日期"
                v-model="tableData.c_bydate"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="营运证好">
            <el-input
              v-model="tableData.c_operation"
              placeholder="请输入营运证好"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="保险到期日期">
           
             <el-form-item prop="date1">
              <el-date-picker
                type="date"
                placeholder="请输入保险到期时间"
                v-model="tableData.c_insurancedateend"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="年间到期日期">
               <el-form-item prop="date1">
              <el-date-picker
                type="date"
                placeholder="年间到期日期"
                v-model="tableData.c_checkdateend"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
         
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="保养公里数设置">
            <el-input
              v-model="tableData.c_maintain"
              placeholder="请输入保养公里数设置"
              type="Number"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
       <el-row>
          <el-col :span="12">
            <el-form-item label="车辆照片">
              <el-upload
                class="upload-demo"
                :action="uploadUrl"
                multiple
                :on-success="handleAvatarSuccess2"
                name="fileList"
                :show-file-list="false"
              >
                <el-button size="small" type="primary">点击上传</el-button>

                <div slot="tip" class="el-upload__tip">
                  只能上传jpg/png文件，且不能查过500k
                </div>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>

         <el-row>
          <el-col :span="12">
            <el-form-item label="保险照片">
              <el-upload
                class="upload-demo"
                :action="uploadUrl"
                multiple
                :on-success="handleAvatarSuccess3"
                name="fileList"
                :show-file-list="false"
              >
                <el-button size="small" type="primary">点击上传</el-button>

                <div slot="tip" class="el-upload__tip">
                  只能上传jpg/png文件，且不能查过500k
                </div>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>

      <el-form-item>
        <el-button type="primary" @click="Eintyes()">保存</el-button>
        <el-button @click="Miss()">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {
     pagess,
     Eintyess,
 } from "@/api/system_base/CheliangApi"; // 引入车辆类别操作api
export default {
  data() {
    return {
      id: this.$route.params.id,
      tableData: [],
        uploadUrl:
        process.env.VUE_APP_BASE_API +
        "services/app/FileManagerService/FilesUpload",
      imageUrl: "",
      addtuname: "",
      addtuname2:"",
    };
  },
  created() {
    this.Page();
  },
  methods: {
     //文件上传
    handleAvatarSuccess2(res, files, fileList) {
      // res.imagerUrl="https://localhost:44311/"+
      res.result.some((f, i) => {
        var that = this;
      
        that.addtuname = f.fileNewName;
        this.imagerUrl = "https://localhost:44311/" + f.fileNewName;
      });
    },
    handleAvatarSuccess3(res, files, fileList) {
      // res.imagerUrl="https://localhost:44311/"+
      res.result.some((f, i) => {
        var that = this;
       
        that.addtuname2 = f.fileNewName;
        this.imagerUrl = "https://localhost:44311/" + f.fileNewName;
      });
    },

    //取消
    Miss(){
      this.$router.push("/cheliang/cheliang");
         },
      //保存
      Eintyes(){
        var thta=this;
        thta.tableData.c_chezhaotu=this.addtuname;
        thta.tableData.c_baoxiantu=this.addtuname2;
          Eintyess(this.tableData).then(
              (r)=>{
                  this.$message("修改成功");
                  this.$router.push("/cheliang/cheliang");
                 
              }
          )
      },
    Page() {
      pagess(this.id).then((r) => {
        console.log("r", r);
        if (r.result != null) {
          var that = this;
          that.tableData = r.result;
        }
      });
    },
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
  },
};
</script>